"use strict";
/**
 * @author zhaojiuyi
 * @date 2022/5/30-9:38
 * @version 1.0.0
 */
import api from '@/network/api';
import {jsonToParse} from "@/util/util";
export default {
  name: "rightUserInfo",
  data() {
    return {
      title: '用户信息',
      yearold: '0000-00-00',
      userInfo: {
        avatarUrl: '',
        nickname:'',
        follows:'',
        followeds:'',
        createTime: '',
        level:'',
        createDays:'',
        signature:''
      }
    }
  },
  methods: {
    getuserinfo(){
      api.getUserInfo().then(res=>{
        if (res.code !== 200) return;
        this.userInfo.avatarUrl = res['profile']['avatarUrl'];
        this.userInfo.nickname = res['profile']['nickname'];
        this.userInfo.follows = res['profile']['follows'];
        this.userInfo.followeds = res['profile']['followeds'];
        this.userInfo.level = res['level'];
        this.userInfo.createDays = res['createDays'];
        this.userInfo.createTime = res['createTime'];
        this.userInfo.signature = res['profile']['signature'];
        this.userInfo = jsonToParse(this.userInfo)
      })
    },
    time(time){
      //注册时间
      let date = new Date(time);//时间戳为10位需*1000，时间戳为13位的话不需乘1000
      let Y = date.getFullYear() + '-';
      let M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
      let D = date.getDate() + ' ';
      // this.yearold = Y + M + D;
      return Y + M + D;
    }
  },
  async mounted() {
    //村龄
    await this.getuserinfo();
  }
}
